<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 调用组件 -->
        <my-component></my-component>
    </div>
    <div id="app2">
        <my-component></my-component>
        <my-header></my-header>
    </div>
    <template id="myT">
        <div @click='fn()'>
            组件2 {{msg}}
        </div>
    </template>
</body>
<script src="js/vue.js"></script>
<script>
    // 定义一
    Vue.component("my-component", Vue.extend({
            template: '<div>组件</div>'
        }))
        // 定义二
    Vue.component("my-component", {
            template: '<div>组件</div>'
        })
        // 定义三
    Vue.component("my-component", {
        template: '#myT',
        data() {
            return {
                msg: 'hello'
            }
        },
        methods: {
            fn() {
                console.log(1);
            }
        }
    })
    Vue.component("myHeader", {
        template: '<header>myHeader</header>'
    })
    let vm = new Vue({
        el: "#app"
    })
    let vm2 = new Vue({
        el: "#app2"
    })
</script>

</html>